<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/gray/window.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css" />
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
		<script type="text/javascript" src="../../../JS/BasicInfomation.js"></script>
	</head>

	<body style="padding: 0px;">
		<form id="ff" method="post">
			<br />
			<table cellpadding="3" class="displaytable" style="padding: 20px;">
				<tr>
					<!--<td width="10%">转换表编号</td>
					<td width="30%">
						<input class="easyui-textbox" name="CONVERTTABLE_ID" style="width:90%;height:25px"></input>
					</td>-->
					<td width="30%">
						<h id="star">* </h>用户组
					</td>
					<td width="65%">
						<input id="input_CUSTOMER_TYPE" class="easyui-combobox" name="CUSTOMER_TYPE" style="width:90%;height:25px" data-options="required:true"></input>
					</td>
				</tr>
				<tr>
					<td>
						<h id="star">* </h>内部产品名称</td>
					<td>
						<input id="input_internal_name" class="easyui-combobox" name="INTERNAL_NAME" style="width:90%;height:25px" data-options="required:true"></input>
					</td>
				</tr>
				<tr>
					<td>
						<h id="star">* </h>原始产品名称</td>
					<td>
						<input class="easyui-textbox" name="ORIGINAL_NAME" style="width:90%;height:25px" data-options="required:true"></input>
					</td>
				</tr>
				<tr>
					<td>
						<h id="star">* </h>原始计量单位</td>
					<td>
						<input style="width:90%;height:25px" class="easyui-textbox" name="ORIGINAL_UNIT" data-options="required:true"></input>
					</td>
				</tr>
				<tr class="hiddentr">
					<td>内部商品ID</td>
					<td>
						<input id="input_INTERNALTRADE_ID" style="width:90%;height:25px" class="easyui-textbox" name="INTERNALTRADE_ID"></input>
					</td>
				</tr>
				<tr class="hiddentr">
					<td>用户组ID</td>
					<td>
						<input id="input_CUSTOMERTYPE_ID" style="width:90%;height:25px" class="easyui-textbox" name="CUSTOMERTYPE_ID"></input>
					</td>
				</tr>
				<tr class="hiddentr">
					<td>ID</td>
					<td>
						<input id="input_ID" style="width:90%;height:25px" class="easyui-textbox" name="ID"></input>
					</td>
				</tr>

			</table>
			<table>
				<div class="submit_button">
					<a class="easyui-linkbutton" onclick="save()" style="width: 100px;"> 保存</a>
					<a class="easyui-linkbutton" onclick="cls()" style="width: 100px;margin-left: 10px;">清空 </a>
				</div>
			</table>
		</form>
		<div id="dlg" class="easyui-dialog" closed="true" style="width:560px;height:400px;padding:10px">
			<iframe id="ifrmEdit" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script type="text/javascript">
		var id = getID();
		var AddDialog;
		$(document).ready(function(){
			if(id != AddFlag) {
			loadRemote();
		}
		});

		function save() {
			SaveData();
		}

		function loadRemote() {
			var pLocation = RemoteLinkAddress + '/logistics/converttable/findbyid.do?ID=' + id;
			$('#ff').form('load', pLocation);
		}

		function cls() {
			$('#ff').form('reset');
		}
		var auth = "admin;" + hex_sha1("admin1");

		function SaveData() {
			var _url = "";
			data = $('#ff').serialize();
			if(id == AddFlag) {
				_url = RemoteLinkAddress + "/logistics/converttable/save.do";
				data=data.replace("&ID=",""); //在新增保存的时候不需要传入ID值
			} else {
				_url = RemoteLinkAddress + "/logistics/converttable/update.do";
			}
			$.post(_url, data,
				function(result) {
					if(result.msg == "success") {
						var parentLocation;
						parentLocation = searchParent("BasicInformationConvertTableList.html");
						parentLocation.dialogClose();
						$.messager.alert({ // show error message
							title: '成功',
							msg: '添加成功'
						});
					} else {
						$.messager.alert({ // show error message
							title: '错误',
							msg: "输入的数据已存在数据库"
						});
					}
				},
				'json');
		}

		$('#input_internal_name').combobox({
			valueField: 'INTERNAL_NAME',
			textField: 'INTERNAL_NAME',
			panelWidth: 200,
			panelHeight: 'auto',
			mode: 'remote',
			method: 'get',
			onChange: function(newValue, oldValue) {
				if(newValue != "" && newValue != undefined) {
					var url = RemoteLinkAddress + "/logistics/internaltrade/findbypinyin?PINYINFIELDNAME=" + newValue.trim();
					$('#input_internal_name').combobox("reload", url);
				}
			},
			onSelect: function(record) {
				$("#input_INTERNALTRADE_ID").textbox('setValue', record.ID);
			}
		});

		$('#input_CUSTOMER_TYPE').combobox({
			valueField: 'CUSTOMER_TYPE',
			textField: 'CUSTOMER_TYPE',
			panelWidth: 200,
			panelHeight: 'auto',
			mode: 'remote',
			method: 'get',
			url: RemoteLinkAddress + "/logistics/customertype/listall.do",
			onSelect: function(record) { //当选中数据后调用该function，并得到该combobox对应的valuefield和textfield，赋值给record
					$('#input_CUSTOMERTYPE_ID').textbox('setValue', record.ID);
				} //调用easyui的textbox的写入值方法，将record中name为CUSTOMER_ID的写入id为customer_id的textbox中
		});
	</script>